<template>
  <div>
    <div class="zd">
      <img src="../../static/images/organize_team/wh.png" />
      <span>
        <router-link :to="{name:'team'}">还没组队？点我去组队用餐！</router-link>
      </span>
    </div>
    <yd-infinitescroll :distance="20" :callback="get_organize_orders" ref="organize_orders">
      <div class="onlist" slot="list">
        <team-result :organizes="item" v-for="(item, index) in organize_orders" :key="index"></team-result>
      </div>
      <span slot="doneTip">没有更多了</span>
    </yd-infinitescroll>
  </div>
</template>
<script>
import teamResult from "@/components/organize_team/team_result";
export default {
  name: "test",
  data() {
    return {
      page_index: 1,
      page_size: 10,
      organize_orders: [
        // {
        //   business_id: 1,
        //   order_id: 1,
        //   logo: require("@/static/images/organize_team/ys.png"),
        //   business_name: "小寨机遇虾堡sds",
        //   order_status: "待消费",
        //   business_pic: require("@/static/images/organize_team/zs.png"),
        //   organize_type: "做东",
        //   order_add_time: "2019-11-12 22:22",
        //   people_num: 5,
        //   total_price: 355
        // },
      ]
    };
  },
  components: {
    teamResult
  },
  mounted() {
    this.get_organize_orders();
  },
  methods: {
    /*
     * 获取组队的待消费的订单
     * 作者：gzt
     * 时间：2019-12-01 22:22:28
     */
    get_organize_orders() {
      let _this = this;
      this.$post(this.$api.organizeteam.organize_team_order, {
        pageNum: this.page_index,
        pageSize: this.page_size,
        request: {
          orderStatus: "WAIT_CONSUM"
        }
      }).then(res => {
        if (res.success) {
          console.log(res.data);
          _this.organize_orders = [
            ..._this.organize_orders,
            ...res.data.result
          ];
          if (res.data && res.data.result.length < _this.page_size) {
            /* 所有数据加载完毕 */
            _this.$refs.organize_orders.$emit("ydui.infinitescroll.loadedDone");
            return;
          }
          /* 单次请求数据完毕 */
          _this.$refs.organize_orders.$emit("ydui.infinitescroll.finishLoad");

          _this.page_index++;
        }
      });
    }
  }
};
</script>
<style scoped>
.zd {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0.3rem;
  font-size: 0.3rem;
}

.zd span {
  text-decoration: blink;
  color: rgb(226, 103, 21);
}

.zd img {
  height: 0.4rem;
  padding-right: 0.1rem;
}

.onlist {
  padding: 0.3rem;
}
</style>
